package com.module.boots.exception;

import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;

/**
 * 全局公共异常类
 * @author：溪云阁
 * @date：2020年5月2日
 */
@Slf4j
public class CommonRuntimeException extends RuntimeException {

    private static final long serialVersionUID = 1L;

    @Setter
    @Getter
    private Object[] params;

    public CommonRuntimeException(Throwable e, Object... params) {
        super(e);
        this.params = params;
    }

    public CommonRuntimeException(Object... params) {
        this(null, params);
    }

    public CommonRuntimeException(Throwable e) {
        this(null, e);
    }

    public CommonRuntimeException() {
    }

    @Override
    public String getMessage() {
        log.error("获取到的错误信息:{}", super.getMessage());
        log.error("获取到的错误内容:{}", super.fillInStackTrace());
        return super.getMessage();
    }

    /**
     * 重写fillInStackTrace 业务异常不需要堆栈信息，提高效率.
     * @author 溪云阁
     * @return
     */
    @Override
    public Throwable fillInStackTrace() {
        return this;
    }
}
